define(function(require, exports, module) {
    var ALL = require("../../common/all"),
        CONFIG = ALL.CONFIG,
        METHOD = ALL.METHOD,
        Dialog = ALL.Dialog,
        Init = ALL.Init;

    var _Dialog = new Dialog({
        title : "提示",
        content : "<p>确定是否提交？</p>",
        text4Btn: ["确定", "取消"],
        class4Btn: ["", "line"]
    });


    var _vm = Init.initVue({
        data : {
            check : {},
            id : null,
            grouplist : [],
            res : {
                user_name : "",
                group_id : "",
                real_name : "",
                phone : "",
                email : "",
            }
        },
        methods: {
            submit : function() {
                this.check.$valid();

                if (!this.check.flag) { return; }

                var obj = {
                    id : _vm.id,
                    phone : _vm.res.phone,
                    email : _vm.res.email
                };

                _Dialog.showUI(function(i) {
                    if (i == 0) {
                        METHOD.loading.show();
                        METHOD.ajax("admin/update",obj,{type : 'post'}).done(function(){
                            METHOD.loading.hide();
                            _vm.getData();
                            METHOD.alert("操作成功");
                        }).fail(function(){
                            METHOD.loading.hide();
                        });
                    }
                    this.hideUI();
                });
            },
            getData : function() {
                METHOD.loading.show();
                METHOD.ajax("admin/detail",{ id:_vm.id }).done(function(json){
                    METHOD.loading.hide();
                    _vm.res = json.data;
                    console.log(json.data)
                }).fail(function(){
                    METHOD.loading.hide();
                });
            }
        }
    });


    METHOD.loading.show();
    METHOD.ajax("admin/group/get_list", { page:1,num:100 }).done(function(json){
        METHOD.loading.hide();
        _vm.grouplist = json.data;
    }).fail(function(){
        METHOD.loading.hide();
    });

    _vm.id = METHOD.getQueryParms("id") || null;

    if (_vm.id) { _vm.getData(); }

});

